<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Get the locale name of the collator</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="collator.geterrormessage.html">« Collator::getErrorMessage</a></li>
      <li style="float: right;"><a href="collator.getsortkey.html">Collator::getSortKey »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.collator.html">Collator</a></li>
    <li>Get the locale name of the collator</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="collator.getlocale" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Collator::getLocale</h1>
  <h1 class="refname">collator_get_locale</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.3.0, PHP 7, PHP 8, PECL intl &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">Collator::getLocale</span> -- <span class="refname">collator_get_locale</span> &mdash; <span class="dc-title">Get the locale name of the collator</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-collator.getlocale-description">
  <h3 class="title">说明</h3>
  <p class="para">
   面向对象风格
  </p>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>Collator::getLocale</strong></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$type</code></span>): <span class="type"><span class="type">string</span>|<span class="type"><span class="type false">false</span></span></span></div>

  <p class="para rdfs-comment">
   过程化风格
  </p>
  <div class="methodsynopsis dc-description"><span class="methodname"><strong>collator_get_locale</strong></span>(<span class="methodparam"><span class="type"><a href="class.collator.html" class="type Collator">Collator</a></span> <code class="parameter">$object</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$type</code></span>): <span class="type"><span class="type">string</span>|<span class="type"><span class="type false">false</span></span></span></div>

  <p class="para rdfs-comment">
   Get collector locale name.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-collator.getlocale-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">object</code></dt>

     <dd>

      <p class="para">
       <span class="classname"><a href="class.collator.html" class="classname">Collator</a></span> object.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">type</code></dt>

     <dd>

      <p class="para">
       You can choose between valid and actual locale (
       <strong><code>Locale::VALID_LOCALE</code></strong> and 
       <strong><code>Locale::ACTUAL_LOCALE</code></strong>,
       respectively).
      </p>
     </dd>

    
   </dl>

  </p>
 </div>



 <div class="refsect1 returnvalues" id="refsect1-collator.getlocale-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Real locale name from which the collation data comes. If the collator was
   instantiated from rules or an error occurred, returns <strong><code>false</code></strong>.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-collator.getlocale-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2289">
    <p><strong>示例 #1 <span class="function"><strong>collator_get_locale()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$coll&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">collator_create</span><span style="color: #007700">(&nbsp;</span><span style="color: #DD0000">'en_US_California'&nbsp;</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$res_val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">collator_get_locale</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$coll</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">Locale</span><span style="color: #007700">::</span><span style="color: #0000BB">VALID_LOCALE&nbsp;</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$res_act&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">collator_get_locale</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$coll</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">Locale</span><span style="color: #007700">::</span><span style="color: #0000BB">ACTUAL_LOCALE&nbsp;</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">printf</span><span style="color: #007700">(&nbsp;</span><span style="color: #DD0000">"Valid&nbsp;locale&nbsp;name:&nbsp;%s\nActual&nbsp;locale&nbsp;name:&nbsp;%s\n"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$res_val</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$res_act&nbsp;</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Requested locale name: en_US_California
Valid locale name: en_US
Actual locale name: en
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-collator.getlocale-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="collator.create.html" class="function" rel="rdfs-seeAlso">collator_create()</a> - Create a collator</span></li>
   </ul>
  </p>
 </div>

</div></div></div></body></html>